﻿/*

  The contents of this file are subject to the Mozilla Public License Version
  1.1 (the "License"); you may not use this file except in compliance with
  the License. You may obtain a copy of the License at 
  
           http://www.mozilla.org/MPL/ 
  
  Software distributed under the License is distributed on an "AS IS" basis,
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  for the specific language governing rights and limitations under the License. 
  
  The Original Code is PEGAS Framework.
  
  The Initial Developer of the Original Code is
  ALCARAZ Marc (aka eKameleon)  <vegas@ekameleon.net>.
  Portions created by the Initial Developer are Copyright (C) 2004-2009
  the Initial Developer. All Rights Reserved.
  
  Contributor(s) :
  
*/
package pegas.geom 
{
    import buRRRn.ASTUce.framework.TestCase;
    
    public class PolarTest extends TestCase 
    {
        public function PolarTest(name:String = "")
        {
            super(name);
        }
        
        public var polar:Polar;
        
        public function setUp():void
        {
            polar = new Polar(100, 45) ;
        }
        
        public function tearDown():void
        {
            polar = undefined ;
        }
        
        public function testConstructor():void
        {
            assertNotNull( polar, "01 - constructor failed.") ;
        }
        
        public function testInterface():void
        {
            assertTrue( polar is Geometry  , "implements Geometry failed.") ;
        }
        
        public function testZERO():void
        {
            var polar:Polar = Polar.ZERO ;
            assertEquals( polar.radius , 0 , "ZERO radius failed." ) ;
            assertEquals( polar.angle  , 0 , "ZERO angle  failed." ) ;
        }
        
        public function testToSource():void
        {
            assertEquals( polar.toSource() , "new pegas.geom.Polar(100,45)", "toSource failed." ) ;
        }
        
        public function testToString():void
        {
            assertEquals( polar.toString() , "[Polar radius:100 angle:45]", "toString failed : " + polar.toString() ) ;
        }
        
        public function testRadius():void
        {
            assertEquals( polar.radius , 100 , "radius property failed." ) ;
        }
        
        public function testAngle():void
        {
            assertEquals( polar.angle , 45 , "angle property failed." ) ;
        }
        
        public function testClone():void
        {
            var clone:Polar = polar.clone() as Polar ;
            assertNotNull( clone , "01 - clone method failed.") ;
            assertEquals( clone , polar ,  "02 - clone method failed." ) ;
        }
        
        public function testEmpty():void
        {
            polar.empty() ;
            assertTrue( polar.equals( Polar.ZERO ) , "empty method failed.") ;
        }
        
        public function testEquals():void
        {
            var p:Polar = new Polar(100, 45) ;
            assertTrue( p.equals( polar ) , "equals method failed.") ;
        }
    }
}
